<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
		"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
	<title>ContentPane DOH test</title>
	<style type="text/css">
		@import "../test.css";
	</style>

	<script type="text/javascript" src="../../../dojo/dojo.js"
		djConfig="isDebug: true"></script>
	<script type="text/javascript">
		dojo.require("doh.runner");
		dojo.require("judo.zone");

		dojo.addOnLoad(function(){
			var zone1;
			var z1sInternal;
			var z1sExternal;

			doh.registerGroup("zone-simple",
				[
					{
						name: "byId",
						setUp: function(t){
							zone1=judo.zone.byId("zone1");
						},
						runTest: function(t){
							if(!zone1)
								throw doh._AssertFailure("zone not found");
						}
					},
					{
						name: "activate-internal",
						timeout: 1200,
						setUp: function(t){
							z1sInternal=dojo.byId('z1sInternal');
						},
						runTest: function(t){
							if(!z1sInternal)
								throw doh._AssertFailure("zone source not found");
							judo.zone.activate(z1sInternal);
							var d = new t.Deferred();
							setTimeout(d.getTestCallback(
								function(){
									t.assertNotEqual(-1, zone1.innerHTML.indexOf('updated z1sInternal'));
								}
							), 1000);
							return d;
						}
					},
					{
						name: "activate-external",
						timeout: 2800,
						setUp: function(t){
						z1sExternal=dojo.byId('z1sExternal');
						},
						runTest: function(t){
							if(!z1sInternal)
								throw doh._AssertFailure("zone source not found");
							judo.zone.activate(z1sExternal);
							var d = new t.Deferred();
							setTimeout(d.getTestCallback(
								function(){
									t.assertNotEqual(-1, zone1.innerHTML.indexOf('updated z1sExternal'));
								}
							), 2500);
							return d;
						}
					}
				]
			);

			var zone2;
			var zone21;
			var z2s;
			var z21s;
			
			
			doh.registerGroup("zone-nested",
					[
						{
							name: "byId",
							setUp: function(t){
								zone2=judo.zone.byId("zone2");
							},
							runTest: function(t){
								if(!zone2)
									throw doh._AssertFailure("zone not found");
							}
						},
						{
							name: "activate-z2s",
							timeout: 1200,
							setUp: function(t){
								z2s=dojo.byId('z2s');
							},
							runTest: function(t){
								if(!z2s)
									throw doh._AssertFailure("zone source not found");
								
								judo.zone.activate(z2s);
								var d = new t.Deferred();
								setTimeout(d.getTestCallback(
									function(){
										t.assertNotEqual(-1, zone2.innerHTML.indexOf('updated z2s'));
									}
								), 1000);
								return d;
							}
						},
						{
							name: "activate-z21s",
							timeout: 2200,
							setUp: function(t){
								z21s=dojo.byId('z21s');
							},
							runTest: function(t){
								if(!z21s)
									throw doh._AssertFailure("zone source not found");
								zone21=judo.zone.byId("zone21");
								if(!zone21)
									throw doh._AssertFailure("zone source not found");
								judo.zone.activate(z21s);
								var d = new t.Deferred();
								setTimeout(d.getTestCallback(
									function(){
										console.log(zone21)
										t.assertNotEqual(-1, zone21.innerHTML.indexOf('updated z21s'));
									}
								), 2000);
								return d;
							}
						}
					]
				);
			
			var zone31;
			var zone32;
			var z3s;
			
			doh.registerGroup("zone-nested",
					[
						{
							name: "byId",
							setUp: function(t){
								zone31=judo.zone.byId("zone31");
								zone32=judo.zone.byId("zone32");
							},
							runTest: function(t){
								if(!(zone31 && zone32))
									throw doh._AssertFailure("zone not found");
							}
						},
						{
							name: "activate-z3s",
							timeout: 1200,
							setUp: function(t){
								z3s=dojo.byId('z3s');
							},
							runTest: function(t){
								if(!z3s)
									throw doh._AssertFailure("zone source not found");
								
								judo.zone.activate(z3s);
								var d = new t.Deferred();
								setTimeout(d.getTestCallback(
									function(){
										t.assertNotEqual(-1, zone31.innerHTML.indexOf('updated z3s'));
										t.assertNotEqual(-1, zone32.innerHTML.indexOf('updated z3s'));
									}
								), 1000);
								return d;
							}
						}
					]
				);

			
			doh.run();
		});
	</script>
</head>
<body class="tundra">
	<div class="zone jz-zone1">
		<a class="jzs jzs-zone1" href="_zone1internal.js" id="z1sInternal">refresh1</a>
	</div>
	<a class="jzs jzs-zone1" href="_zone1external.js" id="z1sExternal">refresh1</a>
	<p>nested zones</p>
	<div class="zone jz-zone2">
		<a class="jzs jzs-zone2" href="_zone2.js" id="z2s">refresh2</a>
		<div class="zone jz-zone21">
			<a class="jzs jzs-zone21" href="_zone21.js" id="z21s">refresh21</a>
		</div>
	</div>
	<div class="zone jz-zone3">
		zone3
		<div class="zone jz-zone31">
			zone31
		</div>
		<div class="zone jz-zone32">
			zone32
		</div>
	</div>
	<a class="jzs jzs-zone3" href="_zone3.js" id="z3s">refresh3132</a>
</body>
</html>
